﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Input_PersonCongratulationPrintForm
 * 类型：       控制层
 * 功能说明：   转正祝贺信打印页面
 * 作者：       徐傲明
 * 创建日期：   2008/02/22
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Master.Bean;
using Shpm.App.Master.Dao;
using System.Globalization;
using Shpm.App.Commons.Utils;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using System.Text.RegularExpressions;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.System;
using Shpm.App.Commons.Utils;
using System.Reflection;
using Shpm.System.Web.Control;
using log4net;

public partial class App_Input_PersonCongratulationPrintForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //接受数据
        string personId = Convert.ToString(Request.QueryString["PERSON_ID"]);

        

        SaleProcessMemberShipBean dataBean = new SaleProcessMemberShipBean();
        SaleProcessMemberShipBean newBean = new SaleProcessMemberShipBean();
        PersonDao Dao = new PersonDao();
        dataBean.PersonId = Convert.ToInt32(personId);
        newBean = Dao.GetEnployee(dataBean);
        string strName = newBean.NameC;
        string strSex = newBean.Sex;

        //打印
        set1(strName, strSex);

    }


    /*名称： set1
    *功能： 数据打印
    *参数： string strName,string strSex
    *返回： 无
    *说明： 无
    */
    private void set1(string strName, string strSex)
    {
        MemoryStream stream = new MemoryStream();


        Document document = new Document(PageSize.A4, 80, 50, 30, 65);



        PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
        document.Open();


        FontFactory.RegisterDirectory("c:\\Windows\\Fonts");

        FontSelector selector = new FontSelector();

        Font font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 22, Font.BOLD, new Color(255, 0, 51));

        selector.AddFont(font);
        string strWord;

        //显示标题
        Paragraph title = new Paragraph(selector.Process("祝  贺  信"));
        //Paragraph title1 = new Paragraph(selector.Process(memberNo));

        title.Alignment = Element.ALIGN_CENTER;

        document.Add(title);

        //显示打印数据
        PdfPTable table = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Paragraph(" "));

        //显示基本资料
        cell.Border = 0;
        table.AddCell(cell);

        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 14, Font.UNDEFINED, new Color(0, 0, 0));
        selector = new FontSelector();
        selector.AddFont(font);
        cell.HorizontalAlignment = Element.ALIGN_LEFT;

        if (strSex == "01")
        {
            cell.Phrase = selector.Process("尊敬的" + strName + "先生:");
        }
        else if (strSex == "02")
        {
            cell.Phrase = selector.Process("尊敬的" + strName + "女士:");
        }
        else
        {
            cell.Phrase = selector.Process("尊敬的" + strName + "先生/女士:");
        }

        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        strWord = "    真诚感谢您在试用期间良好的工作表现和为公司所作的";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "贡献！";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        strWord = "    祝贺您正式转正，成为公司大家庭的一员！";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);


        strWord = "    我们欣赏您______________________________________";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        strWord = "___________________________________________________;";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "同时我们也希望您____________________________________";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "__________________________________________________。";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        strWord = "    公司将充分尊重您的需求与价值，并祝愿您在工作岗位";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "上积极进取，以您的敬业精神和智慧才能，为公司发展作出";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "更大的贡献！";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        strWord = "行政人事部";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        strWord = "亲和源";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        strWord = Convert.ToString(DateTime.Now.Year) + "年" + Convert.ToString(DateTime.Now.Month) + "月" + Convert.ToString(DateTime.Now.Day) + "日";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        document.Add(table);
        document.Close();
        Response.AddHeader("Cache-Control", "cache");
        Response.AddHeader("Content-Type", "application/pdf");
        Response.AddHeader("Content-Length", stream.GetBuffer().Length.ToString());
        // Response.AddHeader("Content-Disposition", "attachment;filename=shpm.pdf");
        Response.BinaryWrite(stream.GetBuffer());

        Response.End();
    }
}
